package enterprise.manage.dao;

import enterprise.manage.entity.Role;
import enterprise.manage.entity.User;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.hibernate.HibernateDao;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: zhenmingyue
 * Date: 2012-11-19
 * Time: 22:23:16
 * To change this template use File | Settings | File Templates.
 */
@Repository
@Transactional
public class UserDao extends HibernateDao<User, Long> {

    @Transactional(isolation = Isolation.READ_UNCOMMITTED)
    public User getByUserName(String userName){
        return  findByUnique("userName",userName);
    } 
     /**
     * 每日统计(分页)
     *
     * @param queryBegin  查询起始日期
     * @param queryEnd    查询结束日期
     * @param pageNo      页号
     * @param pageSize    页大小
     * @param userId      用户的ID
     * @return UserTransactionsSumOfDay    商户收款每日统计列表
     */
//    @Transactional(isolation = Isolation.READ_UNCOMMITTED)
//    public Page<Users> getSumOfDayPage(Calendar queryBegin, Calendar queryEnd, int pageNo,
//                                                          int pageSize, Long userId) {
//        List<Criterion> criterionList = new ArrayList<Criterion>();
//        if (userId != null) {
//            criterionList.add(Restrictions.eq("partner.id", userId));
//        }
//
//        if (queryBegin != null) {
//            criterionList.add(Restrictions.ge("statisticsDate", queryBegin));
//        }
//        if (queryEnd != null) {
//            criterionList.add(Restrictions.lt("statisticsDate", queryEnd));
//        }
//
//        /* criterionList*/
//        Page<UserTransactionsSumOfDay> page = new Page<UserTransactionsSumOfDay>();
//        page.setOrderBy("statisticsDate");
//        page.setOrder("desc");
//        page.setPageSize(pageSize);
//        page.setPageNo(pageNo);
//        Criterion[] criterions = new Criterion[criterionList.size()];
//
//        return findByCriteria(page, criterionList.toArray(criterions));
//    }
}
